﻿using System.Linq;
using NUnit.Framework;
using ProjetoComperio.BusinessLogicLayer;
using ProjetoComperio.DataLayer.Entities;
using System.Web.Mvc;
using ProjetoComperio.Presentation.Web.Controllers;
using ProjetoComperio.Test.FakeData;

namespace ProjetoComperio.Test.WebUI.Controllers
{
    [TestFixture]
    public class EventControllerTest
    {

        FormCollection formCollection;
        EventController eventController;
        EventBLL eventBLL;

        [TestFixtureSetUp]
        public void TestFixtureSetUp()
        {
            eventBLL = new EventBLL();
            eventController = new EventController(eventBLL);
        }

        [SetUp]
        public void SetUp()
        {
            eventBLL.InitializeDataContext(new FakeComperioEntitiesDataModel());
            formCollection = new FormCollection();
        }

        [Test]
        public void TestIndex()
        {
            eventController.Index();
            Assert.IsNotNull(eventController.ViewData["GridSource"] as IQueryable<Event>);

        }

        [Test]
        public void TestCreate()
        {
            //String title = "Title To test" + DateTime.Now.ToString();
            //formCollection["Title"] = title;
            //formCollection["RegisterDate"] = DateTime.Now.ToShortDateString();
            //formCollection["SourceInfo"] = "Fonte de informação";
            //formCollection["Description"] = "Testando";
            //formCollection["Subject"] = "Teste Assunto";
            //formCollection["Location"] = "localização";
            //formCollection["StartDate"] = DateTime.Now.ToShortDateString();
            //formCollection["EndDate"] = DateTime.Now.AddDays(1).ToShortDateString();
            //formCollection["Details"] = "More details";
            //formCollection["Author"] = "Higor C";
            //formCollection["AuthorDescription"] = "A programmer guy";
            //eventController.Create(formCollection);
            //Assert.IsNotNull(eventBLL.RetrieveEvents().FirstOrDefault(x => x.Title == title));
        }

    }
}
